#!/bin/sh
#
#######################################################################
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#######################################################################

# This script sends packages


VERSION=`grep "AC_INIT" configure.ac | sed -e 's/.*\[\([0-9]\.[0-9]\+\)\].*/\1/'`

SEND_PACKAGE=false
SEND_WEBPAGE=false

while test -n "$1"
do
	case "$1" in
	--send-package) SEND_PACKAGE=true;;
	--send-webpage) SEND_WEBPAGE=true;;
	*) echo "ERROR: unknown option \"$1\"."; exit 1;;
	esac
	shift
done

if $SEND_PACKAGE
then
	(
	cd ../packages/apple_emulator-$VERSION
	ncftpput upload.sourceforge.net incoming *
	)
fi

if $SEND_WEBPAGE
then
	(
	mkdir -p tmp
        cd doc/html
        tar cjf ../../tmp/web-page.tar.bz2 .
        cd ../../tmp
        if scp web-page.tar.bz2 alexis_wilke@apple-emulator.sourceforge.net:/home/groups/a/ap/apple-emulator/htdocs/web-page.tar.bz2 \
        && ssh alexis_wilke@apple-emulator.sourceforge.net "cd /home/groups/a/ap/apple-emulator/htdocs/; tar -mxjf web-page.tar.bz2; rm -rf web-page.tar.bz2";
        then
                rm -rf web-page.tar.bz2
        fi
	)
fi

